﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _38 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Staff_Attendance_RuleSetting",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, comment: "考勤组名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    StartTime = table.Column<string>(type: "longtext", nullable: false, comment: "开始时刻（24小时制）")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EndTime = table.Column<string>(type: "longtext", nullable: false, comment: "结束时刻（24小时制）")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsExcludingLegalHolidays = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "法定节假日是否自动排休"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Staff_Attendance_RuleSetting", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Staff_Attendance_CycleSetting",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: false, comment: "工作日名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PeriodType = table.Column<int>(type: "int", nullable: false, comment: "考勤日(PeriodType)"),
                    StaffAttendanceRuleId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "员工规则Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Staff_Attendance_CycleSetting", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Staff_Attendance_CycleSetting_Staff_Attendance_RuleSetting_S~",
                        column: x => x.StaffAttendanceRuleId,
                        principalTable: "Staff_Attendance_RuleSetting",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Staff_Attendance_User",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    UserId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "人员Id", collation: "ascii_general_ci"),
                    UserName = table.Column<Guid>(type: "char(36)", nullable: false, comment: "人员姓名", collation: "ascii_general_ci"),
                    StaffAttendanceRuleId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "员工规则Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Staff_Attendance_User", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Staff_Attendance_User_Staff_Attendance_RuleSetting_StaffAtte~",
                        column: x => x.StaffAttendanceRuleId,
                        principalTable: "Staff_Attendance_RuleSetting",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Staff_Attendance_CycleSetting_StaffAttendanceRuleId",
                table: "Staff_Attendance_CycleSetting",
                column: "StaffAttendanceRuleId");

            migrationBuilder.CreateIndex(
                name: "IX_Staff_Attendance_User_StaffAttendanceRuleId",
                table: "Staff_Attendance_User",
                column: "StaffAttendanceRuleId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Staff_Attendance_CycleSetting");

            migrationBuilder.DropTable(
                name: "Staff_Attendance_User");

            migrationBuilder.DropTable(
                name: "Staff_Attendance_RuleSetting");
        }
    }
}
